# -*- mode: python -*-

Import("env")
Import("wiredtiger")

env = env.Clone()

env.SConscript(
    must_exist=1,
    dirs=["sdam"],
    exports=["env"],
)


def shouldBuildGRPC(myEnv):
    return myEnv.TargetOSIs("linux") and myEnv["ENABLE_GRPC_BUILD"]


clientDriverEnv = env.Clone()
clientDriverEnv.InjectThirdParty("asio")
if shouldBuildGRPC(env):
    clientDriverEnv.InjectThirdParty(libraries=["grpc"])

if wiredtiger:
    env.CppUnitTest(
        target="client_test",
        source=[],
        LIBDEPS=[],
    )

env.CppIntegrationTest(
    target="replica_set_monitor_integration_test",
    source=[
        "replica_set_monitor_integration_test.cpp",
    ],
    LIBDEPS=[
        "$BUILD_DIR/mongo/client/clientdriver_network",
        "$BUILD_DIR/mongo/db/wire_version",
        "$BUILD_DIR/mongo/executor/network_interface_factory",
        "$BUILD_DIR/mongo/executor/network_interface_thread_pool",
        "$BUILD_DIR/mongo/executor/thread_pool_task_executor",
        "$BUILD_DIR/mongo/transport/transport_layer_egress_init",
        "$BUILD_DIR/mongo/util/concurrency/thread_pool",
        "$BUILD_DIR/mongo/util/version_impl",
    ],
)

env.CppUnitTest(
    target="client_rs_test",
    source=[],
    LIBDEPS=[],
)

if shouldBuildGRPC(env):
    clientDriverEnv.CppUnitTest(
        target="dbclient_grpc_stream_test",
        source=[],
        LIBDEPS=[],
    )

env.CppUnitTest(
    target="scoped_db_connection_pool_test",
    source=[],
    LIBDEPS=[],
)

env.CppUnitTest(
    target="dbclient_connection_test",
    source=[],
    LIBDEPS=[],
)

# The following two tests cannot be combined because the second one
# needs to be filtered out for the repl and sharding variants of the
# integration tests.
env.CppIntegrationTest(
    target="client_connpool_integration_test",
    source=[
        "connpool_integration_test.cpp",
    ],
    LIBDEPS=[
        "$BUILD_DIR/mongo/transport/transport_layer_egress_init",
        "$BUILD_DIR/mongo/util/version_impl",
        "clientdriver_network",
    ],
)

env.CppIntegrationTest(
    target="client_dbclient_connection_integration_test",
    source=[
        "dbclient_connection_integration_test.cpp",
    ],
    LIBDEPS=[
        "$BUILD_DIR/mongo/transport/transport_layer_egress_init",
        "$BUILD_DIR/mongo/util/version_impl",
        "clientdriver_network",
    ],
)
